package com.alivc.testmediaplayer.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebView;

import com.alivc.testmediaplayer.R;
import com.alivc.testmediaplayer.utils.CleanLeakUtils;

import java.util.Locale;

/**
 * Created by pengshuang on 21/08/2017.
 */

public class DemoDiagnosisiActivity extends AppCompatActivity {

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_diagnosis);

        webView = (WebView) findViewById(R.id.diagnosis);
        webView.getSettings().setJavaScriptEnabled(true);

        String souce = getIntent().getStringExtra("souce");
        String vid = getIntent().getStringExtra("vid");
        String lang = isZh()?"zh-cn":"en-us";
        webView.loadUrl("http://player.alicdn.com/detection.html?from=android&pd=paas&source="+souce+"&vid="+vid+"&lang="+lang);
    }

    @Override
    protected void onDestroy() {
        CleanLeakUtils.fixInputMethodManagerLeak(this);
        super.onDestroy();
    }


    private boolean isZh() {
        Locale locale = getResources().getConfiguration().locale;
        String language = locale.getLanguage();
        if (language.endsWith("zh"))
            return true;
        else
            return false;
    }
}
